import sqlite3
import numpy as np
from pyecharts import options as opts
from pyecharts.charts import Sankey
from pyecharts.charts import Sunburst
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "../pyecharts-assets/assets/"
dl = [
    ['11','01','0101',430.2],['11','01','0102',7830.2],['11','02','0201',973.0],
    ['11','01','0101',43.2],['11','01','0102',730.2],['11','02','0201',73.0],
    ['22','09','09',40.2],['22','10','1002',830.2],['22','02','1001',783.0],
    ['33','11','1101',30.2],['33','12','1205',780.2],['33','12','1204',93.0]
]

dic = {}
for row in dl:
    dl11,dl01,dl0101,mj = row[0],row[1],row[2],row[3]
    if dl11 in dic:
        if dl01 in dic[dl11]:
            dic[dl11][dl01][dl0101] = mj
        else:
            dic[dl11][dl01]={}
            dic[dl11][dl01][dl0101] = mj
    else:
        dic[dl11] = {}
        dic[dl11][dl01]={}
        dic[dl11][dl01][dl0101] = mj
print(dic)
data = []
for key0 in dic:
    children0 = []
    data.append(opts.SunburstItem(name=key0,children=children0))
    for key1 in dic[key0]:
        children1 = []
        children0.append(opts.SunburstItem(name=key1,children=children1))
        for key2 in dic[key0][key1]:
            children1.append(opts.SunburstItem(name= key2,value=dic[key0][key1][key2]))
